package com.study.compose.beta.view

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.study.compose.beta.R

@Composable
fun LazyRowSample() {
    val data = mutableListOf<Int>()
    for (i in 0..100) {
        data.add(i)
    }
    LazyRow(
        Modifier
            .padding(horizontal = 15.dp)
            .fillMaxSize(),
        verticalAlignment = Alignment.CenterVertically,
        //为item内容添加间距
        horizontalArrangement = Arrangement.spacedBy(20.dp)
    ) {
        //添加item
        items(data) { item ->
            if (item % 2 == 0) {
                Text(
                    text = "item$item",
                )
            } else {
                Image(
                    painter = painterResource(id = R.mipmap.icon_android),
                    contentDescription = ""
                )
            }
        }
    }
}